﻿@model LogisticDatabase.Models.City
@{
    ViewBag.Title = "CityEdit";
}


<h2>CityEdit</h2>

<form method="POST" id="form1">
    Id<input type="text" name="id" id="id"><br>
    Country<input type="text" name="country" id="country"><br>
    Name<input type="text" name="name" id="name"><br>

    <input type="submit" value="Add new city" />
</form>


<script>

    var form = document.getElementById("form1");

    form.addEventListener("submit", function check(event) {
        var did = document.getElementById("id");
        var dcountry = document.getElementById("country");
        var dname = document.getElementById("name");
        if (did.value == "") {
            alert("You must give the id");
            event.preventDefault();
            return;
        }
        if (dcountry.value == "") {
            alert("You must give the country");
            event.preventDefault();
            return;
        }
        if (dname.value == "") {
            alert("You must give the name");
            event.preventDefault();
            return;
        }
        if (dcountry.value.search(/\d/i) != -1) {
            alert("Do no give number to country");
            event.preventDefault();
            return;
        }
        if (dname.value.search(/\d/i) != -1) {
            alert("Do not give number to name");
            event.preventDefault();
            return;
        }



    });
</script>

